package com.example.demo.hello;

import com.example.demo.constant.RqConstant;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: anlu
 * @Date: 2021/06/24
 * @Description: 默认发送
 */
@Component
public class DefaultSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(String msg){
        String sendMsg = msg +"---"+ System.currentTimeMillis();
        System.out.println("sender ："+sendMsg);
        // 发送QUEUE_HELLO消息
        this.rabbitTemplate.convertAndSend(RqConstant.QUEUE_HELLO,sendMsg);
        this.rabbitTemplate.convertAndSend("11",sendMsg);
        // 发送QUEUE_USER消息
        this.rabbitTemplate.convertAndSend(RqConstant.QUEUE_USER,sendMsg);

    }
}
